package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

public class Test {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context
                =new AnnotationConfigApplicationContext("demo1");
        User user=(User)context.getBean(User.class);
        System.out.println(user);
    }
}
@Component
class User {
    public void sayHi(){
        System.out.println("say:Hi");
    }
}